<template>
  <div  class="c-range-picker display-inline">
     <a-range-picker  :ranges="ranges" :format="dateFormat" @change="onChangeDataPicker" />
  </div>
</template>
<script>
import moment from "moment"

export default {
   props: {
     dateFormat: {
      type: String,
      default: 'YYYY-MM-DD'
    },

   },
  data() {
    return {
       ranges:{
              今天: [moment().startOf('day'), moment()],
              昨天: [
                moment()
                  .startOf('day')
                  .subtract(1, 'days'),
                moment()
                  .endOf('day')
                  .subtract(1, 'days')
              ],
              近一周: [
                moment()
                  .startOf('day')
                  .subtract(1, 'weeks'),
                moment()
              ],
              近一个月: [
                moment()
                  .startOf('day')
                  .subtract(1, 'months'),
                moment()
              ],
              近三个月: [
                moment()
                  .startOf('day')
                  .subtract(3, 'months'),
                moment()
              ],
               
            },
    };
  },
  created(){
  },
  methods: {
    
    onChangeDataPicker(val,dateString){
      //返回时间戳
      this.$emit('change', [moment(dateString[0]).valueOf(),moment(dateString[1]).valueOf()]);
    }
  },
};
</script>

<style lang="less" scoped>
  .pagination-content{
    flex: 1;
    text-align: right;
    margin: 25px 0 20px 20px;
  }
  
</style>